#include <iostream>

class Complex {
private:
    double real;
    double imaginary;
public:
    Complex(double r = 0.0, double i = 0.0) : real(r), imaginary(i) {}
    
    // 输入输出运算符重载
    friend std::ostream& operator<<(std::ostream& os, const Complex& c) {
        os << "(" << c.real << "+" << c.imaginary << "i)";
        return os;
    }
    
    friend std::istream& operator>>(std::istream& is, Complex& c) {
        std::cout << "Real part: ";
        is >> c.real;
        std::cout << "Imaginary part: ";
        is >> c.imaginary;
        return is;
    }
    
    // 加法运算符重载
    Complex operator+(const Complex& c) const {
        return Complex(real + c.real, imaginary + c.imaginary);
    }
    
    // 减法运算符重载
    Complex operator-(const Complex& c) const {
        return Complex(real - c.real, imaginary - c.imaginary);
    }
    
    // 乘法运算符重载
    Complex operator*(const Complex& c) const {
        double r = real * c.real - imaginary * c.imaginary;
        double i = real * c.imaginary + imaginary * c.real;
        return Complex(r, i);
    }
    
    // 除法运算符重载
    Complex operator/(const Complex& c) const {
        double denominator = c.real * c.real + c.imaginary * c.imaginary;
        double r = (real * c.real + imaginary * c.imaginary) / denominator;
        double i = (imaginary * c.real - real * c.imaginary) / denominator;
        return Complex(r, i);
    }
    
    // 赋值加法运算符重载
    Complex& operator+=(const Complex& c) {
        real += c.real;
        imaginary += c.imaginary;
        return *this;
    }
    
    // 后缀递增运算符重载
    Complex operator++(int) {
        Complex c(*this);
        ++real;
        ++imaginary;
        return c;
    }
    
    // 前缀递增运算符重载
    Complex& operator++() {
        ++real;
        ++imaginary;
        return *this;
    }
};

int main() {
    Complex c1(1.0, 2.0);
    Complex c2(3.0, 4.0);
    std::cout << "c1 = " << c1 << std::endl;
    std::cout << "c2 = " << c2 << std::endl;
    
    Complex c3 = c1 + c2;
    std::cout << "c1 + c2 = " << c3 << std::endl;
    
    Complex c4 = c1 - c2;
    std::cout << "c1 - c2 = " << c4 << std::endl;
    
    Complex c5 = c1 * c2;
    std::cout << "c1 * c2 = " << c5 << std::endl;
    
    Complex c6 = c1 / c2;
    std::cout << "c1 / c2 = " << c6 << std::endl;
    
    return 1;
  }
